<?php

namespace common\behavior;


use common\service\MessageService;
use common\service\TimelogService;

/**
 * timelog停止通知
 */
class TimelogStoppedNotifyUserBehavior
{
    /**
     * @param $timelog
     * @return void
     */
    public function run($timelog)
    {
        try {
            $timelogDetailData = TimelogService::getInstance()->queryTimeLogDetailData(['timelog.id' => $timelog['id']]);
            if (empty($timelogDetailData)) {
                return;
            }
            MessageService::getInstance()->notifyUserEvent($timelog['created_by'], 'timelog_stopped', $timelogDetailData[0]);
        } catch (\Throwable $e) {
            trace(format_exception_info($e), 'ERR');
        }
    }
}
